-- dungeon
-- Created by chengb Oct/22/2015
-- 关卡排行榜子模块

-- 内部函数声明
local whenDungeonScoreRefresh;

-- 注册迷宫得分刷新的事件
EventMgr.register("gamecenter_leaderboard/dungeon", event.DUNGEON_SCORE_REFRESH, function(args)
    whenDungeonScoreRefresh(args);
end);

-- 迷宫得分刷新的事件回调
function whenDungeonScoreRefresh(args)
    local dungeonId = args.dungeonId;
    local score     = args.score;
    
    local ids = GameCenterLeaderboardM.getIdsByRule("dungeon");
    for _, id in pairs(ids) do
        if GameCenterLeaderboardM.query(id, "area_id") == dungeonId then
            -- 尝试提交该关卡的分数
            GameCenterLeaderboardM.submitScore(id, score);
        end
    end
end
